<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../static/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=QVuUYF24e5Fvz37MYR0gyGtC"></script>
<link rel="stylesheet" type="text/css" href="../static/cymain.css" />
<script src="../static/artDialog/jquery.artDialog.js?skin=default"></script>
<script src="../static/artDialog/plugins/iframeTools.js"></script>
<style type="text/css">
body, html {width: 100%;height: 100%;overflow: hidden;margin:0;font: 12px/1.5 Microsoft YaHei,Helvitica,Verdana,Arial,san-serif;}
a:hover, a:active {
text-decoration: none;
color: #090;
}
#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
#l-map{height:100%;width:100%;}
</style>
</head>
<body id="nv_member">
<input type="hidden" id="longitude" value="0" />
<input type="hidden" id="latitude" value="0" />
<input type="hidden" id="mapPoint" value="0" />

<div class="ftip" style="margin:0">拖动红色图标到相应位置然后点击右侧链接-><a id="ok" href="###">已经设定好，关闭该页面</a></div>
<div id="l-map"></div>
<script type="text/javascript">
if (art.dialog.data('mapPoint')) {
	document.getElementById('longitude').value = art.dialog.data('longitude');// 获取由主页面传递过来的数据
	document.getElementById('latitude').value = art.dialog.data('latitude');
	document.getElementById('mapPoint').value = art.dialog.data('mapPoint');
};
// 关闭并返回数据到主页面
document.getElementById('ok').onclick = function () {
	var origin = artDialog.open.origin;
	var longitudeinput = origin.document.getElementById('longitude');
	var latitudeinput = origin.document.getElementById('latitude');
	var mapPointinput = origin.document.getElementById('map');
	longitudeinput.value = $('#longitude').attr('value');
	latitudeinput.value = $('#latitude').attr('value');
	mapPointinput.value = $('#mapPoint').attr('value');
	art.dialog.close();
};


var map = new BMap.Map("l-map");
var point = new BMap.Point($('#longitude').val(),$('#latitude').val());
map.centerAndZoom(point,12);
map.enableScrollWheelZoom();                            //启用滚轮放大缩小
function myFun(result){
	var cityName = result.name;
	if($('#longitude').val()==0||$('#longitude').val()==''){
		map.setCenter(cityName);
		p = new BMap.Point(result.center.lng,result.center.lat);
	}else{
		p = new BMap.Point($('#longitude').val(),$('#latitude').val());
	}
	var marker = new BMap.Marker(p);
	marker.enableDragging();
	map.addOverlay(marker);

	marker.addEventListener("dragend", function(e){
		$('#longitude').attr('value',e.point.lng);
		$('#latitude').attr('value',e.point.lat);
		$('#mapPoint').attr('value','{"longitude":' + e.point.lng + ',"latitude":' + e.point.lat + '}');
	})
}

var myCity = new BMap.LocalCity();
var p=myCity.get(myFun);

</script>
</body>
</html>